#!/bin/bash
#
#   This file is part of poat.
#
#   poat is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   poat is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with poat.  If not, see <http://www.gnu.org/licenses/>.
#

export TARFILE=$1
export UPLOADPATH=$2
export RESULTS=$3
export TMP=$4
export LANG="en_US"

if [ -f $RESULTS ]
then
	rm -f $RESULTS
fi

tar -xf $UPLOADPATH/$TARFILE -C $TMP

cd $TMP

find . -iname "*.po" | while read pofile
do
	filename=`echo $pofile | cut -f2 -d'/'`
	if `msgfmt --check-header $pofile >& /dev/null`
	then
		echo -e $filename:1>> $RESULTS
	else
		echo -e $filename:2>> $RESULTS
	fi
done

rm -f messages.mo
#tar -Pcz --remove-files -f $UPLOADPATH/$TARFILE *.po